package com.yanqu.road.server.cmd.activity.foxcard;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.FoxCardProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.foxcard.FoxCardModule;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_FOXCARD_FAST_PASS_STAGE, desc = "快速通关非无尽关卡")
public class FoxCardFastPassCmd extends AbstractCommand {
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        FoxCardProto.FoxCardFastPassReqMsg reqMsg = FoxCardProto.FoxCardFastPassReqMsg.parseFrom(packet.getBytes());
        ret = player.getModule(FoxCardModule.class).fastPassStage(reqMsg.getActivityId(), reqMsg.getStageId());
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret > 0) {
            //获得注解的code
            int code = this.getClass().getAnnotation(Cmd.class).code();
            int backClientProtocol = code % 10000;
            player.sendPacket(backClientProtocol, FoxCardProto.FoxCardTreeLvUpRespMsg.newBuilder().setRet(ret));
        }
    }
}
